// By Xeno
// Commented/Edited by Tyrghen

// Waits for the player to be intialized
#define __waitpl [] spawn {waitUntil {!isNull player};X_INIT = true}
// Logs messages to the diag_log in the format (time)[scriptName]: Message
#define __logMsg(script, msg) diag_log Format["(%1)[%2]: %3",diag_tickTime, #script, msg]
// Compile a file and place the resulting code in a Function Variable of the given name.
#define __cppfln(xdfunc,xfile2) xdfunc = compile preprocessFileLineNumbers #xfile2
// Compile a file and executes the code directly.
#define __ccppfln(xfile1) call compile preprocessFileLineNumbers #xfile1
// Check whether the given unit is local to the computer or handled in another system (server or another client)
#define __notlocalexit(xtheunit) if (!local xtheunit) exitWith {}
// Gets and sets variables on the player object.
#define __playerGetVar(pvarname) (player getVariable #pvarname)
#define __playerSetVar player setVariable
// Gets and sets variables on the HeliPad object used to store the global server status.
// Ex: Air support is enabled at the beginning of the game, then the course of actions during the game
//     makes that Artillery got disabled. When a player Join In Progress, the Init.sqf says that the Artillery is enabled... which is false.
//     So in place of calling a global var (local to the player), you use a variable stored on a vehicle which has been
//     automatically synced, even for players who JIP.
#define __XJIPGetVar(jvarname) (JIP_HINV getVariable #jvarname)
#define __XJIPSetVar JIP_HINV setVariable
// Get/Set Mission Namespace variables
#define __getMNsVar(mvarname) (missionNamespace getVariable #mvarname)
#define __mNsSetVar missionNamespace setVariable

// uncomment/comment for debug messages
//#define __DEBUG_NET(dscript,dmsg) if (isServer) then {diag_log format ['NET: %1: dmsg = %2', dscript,dmsg]} else {server globalChat format ['NET: %1: dmsg = %2', dscript,dmsg];diag_log format ['NET: %1: dmsg = %2', dscript,dmsg]};
#define __DEBUG_NET(dscript,dmsg)
//#define __DEBUG_SERVER(dscript,dmsg) if (isServer) then {diag_log format ['%1: dmsg = %2', dscript,dmsg]};
#define __DEBUG_SERVER(dscript,dmsg)
//#define __DEBUG_CLIENT(dscript,dmsg) if (X_Client) then {_dm = format ['%1: dmsg = %2', dscript,dmsg];player sideChat _dm;diag_log _dm};
#define __DEBUG_CLIENT(dscript,dmsg)

#define __MACRO_KNOWN__
#define __DEBUG__
